/*
============================================================================
 Name        : Ind.cpp
 Author      : 
 Version     :
 Copyright   : 
 Description : CInd implementation
============================================================================
*/

#include "Ind.h"
#include "eStockappui.h"
#include "Global.h"
#include "Field.h"
#include <eStock_L2hy.rsg>

CInd::CInd(CBlockPicHis* outerPic):
m_pGlobal(eStockUI->m_Globe),
p_OuterPic(outerPic),
m_nExpSize(0),
m_lMax(0),
m_lMin(0),
m_bCalcMM(EFalse)
{
}

CInd::~CInd()
{
	if(m_pstrExp != NULL)
	{
		m_pstrExp->Reset();
		delete m_pstrExp;
	}
}

CInd* CInd::NewLC(CBlockPicHis* outerPic)
{
	CInd* self = new (ELeave)CInd(outerPic);
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
}

CInd* CInd::NewL(CBlockPicHis* outerPic)
{
	CInd* self=CInd::NewLC(outerPic);
	CleanupStack::Pop(); // self;
	return self;
}

void CInd::ConstructL()
{
}

TInt64 CInd::GetExpValue(const TInt& nDayPos,const TInt& nExpPos)
{
	return p_OuterPic->m_vDay[nDayPos].m_plInd[nExpPos];
}

TInt CInd::GetExpFirst(const TInt& nExpPos)
{
	return p_OuterPic->m_pnFirstInd[nExpPos];
}

void CInd::InitExp(const CDesCArray& /*pstrName*/)
{
}

TInt CInd::GetDataLength()
{
	return 7;
}

void CInd::WriteData(TDes8& /*aPtr*/)
{
}

TInt CInd::Value2Y(const TInt64& lValue)
{
	return p_OuterPic->Volume2Y(lValue);
}

void CInd::Draw(CFbsBitGc& g, const TInt& nFirst, const TInt& nDay)
{
	for (TInt j = 0; j<m_nExpSize; j++)
	{
		DrawLine(g,j, nFirst, nDay, m_pGlobal->g_rgbInd[j]);
	}
}

void CInd::DrawCheck(CFbsBitGc& g, const TInt& anX, const TInt& nY, 
			   const TInt& nPos, const TInt16& sFieldID)
{
	TInt nX = anX;
	m_pGlobal->DrawString(g, m_strName, nX, nY-m_pGlobal->g_nFontSmallHeight, LEFT, m_pGlobal->g_rgbHighlight, 2);
	nX += m_pGlobal->GetStringWidth(m_strName, 2);

	TField field;
	field.m_nFont = 2;
	if (sFieldID==VOLUME)
		field.m_nGoodsID = 1;
	else
		field.m_nGoodsID = p_OuterPic->m_goods.m_nGoodsID;
	field.m_nClose = p_OuterPic->m_goods.m_nClose;
	field.m_sID = sFieldID;

	TInt nDay = p_OuterPic->m_vDay.Count();
	for (TInt i=0; i<m_nExpSize; i++)
	{
		TBuf<30> str;
		TBuf<16> temp;
		str.Copy((*m_pstrExp)[i]);

		if (GetExpFirst(i)>=0)
		{
			if (nPos>=0&&nPos<nDay)
				field.m_lValue = GetExpValue(nPos, i);
			else
				field.m_lValue = 0;
			field.GetString(temp);
			str.Append(temp);
		}
		m_pGlobal->DrawString(g, str, nX, nY-m_pGlobal->g_nFontSmallHeight, LEFT, m_pGlobal->g_rgbInd[i], 2);
		nX += (m_pGlobal->GetStringWidth(str, 2) + m_pGlobal->GetStringWidth(_L("1"), 2));
	}
}

void CInd::DrawLine(CFbsBitGc& g, const TInt& nExpPos, const TInt& nFirst, const TInt& nDay, const TRgb& nRGB)
{
	TInt nExpFirst = GetExpFirst(nExpPos);
	if (nExpFirst<0)
		return;

	g.SetPenColor(nRGB);
	g.SetPenStyle(CGraphicsContext::ESolidPen);
	TInt nLastX = -1;
	TInt nLastY = -1;
	for (TInt i=nFirst; i<nDay; i++)
	{
		if (i>=nExpFirst)
		{
			TInt nX = p_OuterPic->Pos2X(i-nFirst);
			TInt nY = Value2Y(GetExpValue(i, nExpPos));
			if (nLastX<0 || nLastY<0)
			{
				if (i-nFirst>0 && i>nExpFirst)
				{
					nLastX = p_OuterPic->Pos2X(i-nFirst-1);
					THisDay dayLast = p_OuterPic->m_vDay[i-1];
					nLastY = Value2Y(dayLast.m_plInd[nExpPos]);
				}
				else
				{
					nLastX = nX;
					nLastY = nY;
				}
			}
			g.DrawLine(TPoint(nLastX, nLastY), TPoint(nX, nY));
			nLastX = nX;
			nLastY = nY;
		}
	}
}
	
void CInd::DrawVolume(CFbsBitGc& g, const TInt& nExpPos,const TInt& nFirst, const TInt& nDay)
{
	TInt nExpFirst = GetExpFirst(nExpPos);
	if (nExpFirst<0)
		return;

	TInt nW =(p_OuterPic->m_nWidthPerDay/2)-1;
	TInt nY0 = Value2Y(0);

	for (TInt i=nFirst; i<nDay; i++)
	{
		THisDay day = p_OuterPic->m_vDay[i];
		TInt nX = p_OuterPic->Pos2X(i-nFirst);
		TInt nY = Value2Y(GetExpValue(i, nExpPos));
		if (day.m_nClose>=day.m_nOpen)
		{
			if (nY==nY0)
			{
				g.SetPenColor(m_pGlobal->g_rgbRise);
				g.DrawLine(TPoint(nX-nW, nY0), TPoint(nX+nW, nY0));
			}
			else
			{
				CGlobal::DrawRect(g,TRect(TPoint(nX-nW, nY), TSize(nW*2+1, nY0-nY+1)),
					m_pGlobal->g_rgbRise);
			}
		}
		else
		{
			if (nY==nY0)
			{
				g.SetPenColor(m_pGlobal->g_rgbPicFall);
				g.DrawLine(TPoint(nX-nW, nY0), TPoint(nX+nW, nY0));
			}
			else
			{
				CGlobal::DrawRect(g,TRect(TPoint(nX-nW, nY), TSize(nW*2+1, nY0-nY+1)),
					m_pGlobal->g_rgbPicFall,m_pGlobal->g_rgbPicFall);
			}
		}
	}
}

void CInd::DrawStick(CFbsBitGc& g, const TInt& nExpPos,const TInt& nFirst, const TInt& nDay)
{
	TInt nExpFirst = GetExpFirst(nExpPos);
	if (nExpFirst<0)
		return;

	TInt nY0 = Value2Y(0);
	g.SetPenStyle(CGraphicsContext::ESolidPen);
	for (TInt i=nFirst; i<nDay; i++)
	{
		TInt64 lExpValue = GetExpValue(i, nExpPos);
		TInt nX = p_OuterPic->Pos2X(i-nFirst);
		TInt nY = Value2Y(lExpValue);
		if (lExpValue>=0)
			g.SetPenColor(m_pGlobal->g_rgbRise);
		else
			g.SetPenColor(m_pGlobal->g_rgbFall);
		g.DrawLine(TPoint(nX, nY0), TPoint(nX, nY));
	}
}

void CInd::CalcMM(const TInt& nFirst, const TInt& nDay)
{
	m_bCalcMM = EFalse;
	for (TInt j = 0; j<m_nExpSize; j++)
	{
		TInt tmp = GetExpFirst(j);
		if (GetExpFirst(j)>=0)
			CalcMM(j, nFirst, nDay);
	}
	if (m_lMax-m_lMin<100)
				m_lMax = m_lMin+100;
}

void CInd::CalcMM( const TInt& nExpPos,const TInt& nFirst, const TInt& nDay)
{
	for (TInt i=nFirst; i<nDay; i++)
	{
		if (i>=GetExpFirst(nExpPos))
		{
			TInt64 lValue = GetExpValue(i, nExpPos);
			if (!m_bCalcMM)
			{
				m_lMax = m_lMin = lValue;
				m_bCalcMM = ETrue;
			}
			else
			{
				if (m_lMax<lValue)
					m_lMax = lValue;
				if (m_lMin>lValue)
					m_lMin = lValue;
			}
		}
	}
}


CInd_MA::~CInd_MA()
{
}

CInd_MA::CInd_MA(CBlockPicHis* outerPic):CInd(outerPic)
{
}


CInd_MA* CInd_MA::NewLC(CBlockPicHis* outerPic)
{
	CInd_MA* self = new (ELeave)CInd_MA(outerPic);
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
}

CInd_MA* CInd_MA::NewL(CBlockPicHis* outerPic)
{
	CInd_MA* self=CInd_MA::NewLC(outerPic);
	CleanupStack::Pop(); // self;
	return self;
}

void CInd_MA::ConstructL()
{
	m_nExpSize = 3;
	m_strName.Copy(_L("MA "));
	m_pstrExp = new(ELeave)CDesCArrayFlat(3);
	for (TInt i=0; i<3; i++)
	{
		TBuf<20> temp;
		temp.AppendNum(m_pGlobal->m_pnParam[i]);
		temp.Append(_L("="));
		m_pstrExp->AppendL(temp);
	}
}

TInt64 CInd_MA::GetExpValue(const TInt& nDayPos,const TInt& nExpPos)
{
	return p_OuterPic->m_vDay[nDayPos].m_pnMA[nExpPos];
}

TInt CInd_MA::GetExpFirst(const TInt& nExpPos)
{
	return p_OuterPic->m_pnFirstMA[nExpPos];
}

void CInd_MA::WriteData(TDes8& aBuf)
{
	CGlobal::WriteInt8L(aBuf,3);
	for (TInt i=0; i<3; i++)
		CGlobal::WriteInt16L(aBuf,(TInt16)(m_pGlobal->m_pnParam[i]));
}

TInt CInd_MA::Value2Y(const TInt64& lValue)
{
	return p_OuterPic->Price2Y(lValue);
}


//class CInd_VMA
CInd_VMA::~CInd_VMA()
{
}

CInd_VMA::CInd_VMA(CBlockPicHis* outerPic):CInd(outerPic)
{
}

CInd_VMA* CInd_VMA::NewLC(CBlockPicHis* outerPic)
{
	CInd_VMA* self = new (ELeave)CInd_VMA(outerPic);
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
}

CInd_VMA* CInd_VMA::NewL(CBlockPicHis* outerPic)
{
	CInd_VMA* self=CInd_VMA::NewLC(outerPic);
	CleanupStack::Pop(); // self;
	return self;
}

void CInd_VMA::ConstructL()
{
	m_nExpSize = 3;
	m_strName.Copy(KNullDesC);
	m_pstrExp = new(ELeave)CDesCArrayFlat(3);
	m_pstrExp->AppendL(_L("VOL="));
	for (int i=0; i<2; i++)
	{
		TBuf<20> temp;
		temp.AppendNum(m_pGlobal->m_pnParam[i+3]);
		temp.Append(_L("="));
		m_pstrExp->AppendL(temp);
	}
}

TInt CInd_VMA::GetDataLength()
{
	return 5;
}

void CInd_VMA::WriteData(TDes8& aBuf)
{
	CGlobal::WriteInt8L(aBuf,2);

	for (TInt i=0; i<2; i++)
		CGlobal::WriteInt16L(aBuf,(TInt16)(m_pGlobal->m_pnParam[i+3]));
}

void CInd_VMA::CalcMM(const TInt& nFirst,const TInt& nDay)
{
	CInd::CalcMM(nFirst, nDay);
	m_lMin = 0;
}

void CInd_VMA::Draw(CFbsBitGc& g, const TInt& nFirst, const TInt& nDay)
{
		DrawLine(g, 1, nFirst, nDay, m_pGlobal->g_rgbInd[1]);
		DrawLine(g, 2, nFirst, nDay, m_pGlobal->g_rgbInd[2]);
		DrawVolume(g, 0, nFirst, nDay);
}




CInd_MACD::~CInd_MACD()
{

}
CInd_MACD::CInd_MACD(CBlockPicHis* outerPic):CInd(outerPic)
{

}


CInd_MACD* CInd_MACD::NewLC(CBlockPicHis* outerPic)
{
	CInd_MACD* self = new (ELeave)CInd_MACD(outerPic);
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
}

CInd_MACD* CInd_MACD::NewL(CBlockPicHis* outerPic)
{
	CInd_MACD* self=CInd_MACD::NewLC(outerPic);
	CleanupStack::Pop(); // self;
	return self;
}

void CInd_MACD::ConstructL()
{
	m_nExpSize = 3;
	m_strName.Copy(KNullDesC);
	
	m_pstrExp = new(ELeave)CDesCArrayFlat(3);
	m_pstrExp->AppendL(_L("DIF="));
	m_pstrExp->AppendL(_L("DEA="));
	m_pstrExp->AppendL(_L("MACD="));
}


void CInd_MACD::WriteData(TDes8& aBuf)
{

	CGlobal::WriteInt8L(aBuf,3);

	for (TInt i=0; i<3; i++)
		CGlobal::WriteInt16L(aBuf,(TInt16)(m_pGlobal->m_pnParam[i+6]));
}


void CInd_MACD::Draw(CFbsBitGc& g, const TInt& nFirst, const TInt& nDay)
{
		DrawLine(g, 0, nFirst, nDay, m_pGlobal->g_rgbInd[0]);
		DrawLine(g, 1, nFirst, nDay, m_pGlobal->g_rgbInd[1]);
		DrawStick(g, 2, nFirst, nDay);
}




CInd_KDJ::~CInd_KDJ()
{

}
CInd_KDJ::CInd_KDJ(CBlockPicHis* outerPic):CInd(outerPic)
{

}


CInd_KDJ* CInd_KDJ::NewLC(CBlockPicHis* outerPic)
{
	CInd_KDJ* self = new (ELeave)CInd_KDJ(outerPic);
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
}

CInd_KDJ* CInd_KDJ::NewL(CBlockPicHis* outerPic)
{
	CInd_KDJ* self=CInd_KDJ::NewLC(outerPic);
	CleanupStack::Pop(); // self;
	return self;
}

void CInd_KDJ::ConstructL()
{
	m_nExpSize = 3;
	m_strName.Copy(KNullDesC);

	m_pstrExp = new(ELeave)CDesCArrayFlat(3);
	m_pstrExp->AppendL(_L("K="));
	m_pstrExp->AppendL(_L("D="));
	m_pstrExp->AppendL(_L("J="));
}


void CInd_KDJ::WriteData(TDes8& aBuf)
{
	CGlobal::WriteInt8L(aBuf,3);

	for (TInt i=0; i<3; i++)
		CGlobal::WriteInt16L(aBuf,(TInt16)(m_pGlobal->m_pnParam[i+9]));
}

void CInd_KDJ::CalcMM(const TInt& /*nFirst*/,const TInt& /*nDay*/)
{
	m_bCalcMM = ETrue;
	m_lMax = 100000;
	m_lMin = 0;
}




CInd_RSI::~CInd_RSI()
{

}
CInd_RSI::CInd_RSI(CBlockPicHis* outerPic):CInd(outerPic)
{

}


CInd_RSI* CInd_RSI::NewLC(CBlockPicHis* outerPic)
{
	CInd_RSI* self = new (ELeave)CInd_RSI(outerPic);
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
}

CInd_RSI* CInd_RSI::NewL(CBlockPicHis* outerPic)
{
	CInd_RSI* self=CInd_RSI::NewLC(outerPic);
	CleanupStack::Pop(); // self;
	return self;
}

void CInd_RSI::ConstructL()
{
	m_nExpSize = 2;
	m_strName.Copy(_L("RSI"));
	m_pstrExp = new(ELeave)CDesCArrayFlat(2);
	for (TInt i=0; i<2; i++)
	{
		TBuf<20> temp;
		temp.AppendNum(m_pGlobal->m_pnParam[i+12]);
		temp.Append(_L("="));
		m_pstrExp->AppendL(temp);
	}
}

TInt CInd_RSI::GetDataLength()
{
	return 5;
}

void CInd_RSI::WriteData(TDes8& aBuf)
{
	CGlobal::WriteInt8L(aBuf,2);

	for (TInt i=0; i<2; i++)
		CGlobal::WriteInt16L(aBuf,(TInt16)(m_pGlobal->m_pnParam[i+12]));
}

void CInd_RSI::CalcMM(const TInt& /*nFirst*/,const TInt& /*nDay*/)
{
	m_bCalcMM = ETrue;
	m_lMax = 100000;
	m_lMin = 0;
}






CInd_WR::~CInd_WR()
{

}

CInd_WR::CInd_WR(CBlockPicHis* outerPic):CInd(outerPic)
{

}


CInd_WR* CInd_WR::NewLC(CBlockPicHis* outerPic)
{
	CInd_WR* self = new (ELeave)CInd_WR(outerPic);
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
}

CInd_WR* CInd_WR::NewL(CBlockPicHis* outerPic)
{
	CInd_WR* self=CInd_WR::NewLC(outerPic);
	CleanupStack::Pop(); // self;
	return self;
}

void CInd_WR::ConstructL()
{
	m_nExpSize = 1;
	m_strName.Copy(_L("WR"));
	m_pstrExp = new(ELeave)CDesCArrayFlat(1);

	TBuf<20> temp;
	temp.AppendNum(m_pGlobal->m_pnParam[15]);
	temp.Append(_L("="));
	m_pstrExp->AppendL(temp);
}

TInt CInd_WR::GetDataLength()
{
	return 3;
}

void CInd_WR::WriteData(TDes8& aBuf)
{
	CGlobal::WriteInt8L(aBuf,1);
	CGlobal::WriteInt16L(aBuf,(TInt16)(m_pGlobal->m_pnParam[15]));
}

void CInd_WR::CalcMM(const TInt& /*nFirst*/,const TInt& /*nDay*/)
{
	m_bCalcMM = ETrue;
	m_lMax = 100000;
	m_lMin = 0;
}



CInd_VR::~CInd_VR()
{

}

CInd_VR::CInd_VR(CBlockPicHis* outerPic):CInd(outerPic)
{

}


CInd_VR* CInd_VR::NewLC(CBlockPicHis* outerPic)
{
	CInd_VR* self = new (ELeave)CInd_VR(outerPic);
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
}

CInd_VR* CInd_VR::NewL(CBlockPicHis* outerPic)
{
	CInd_VR* self=CInd_VR::NewLC(outerPic);
	CleanupStack::Pop(); // self;
	return self;
}

void CInd_VR::ConstructL()
{
	m_nExpSize = 1;
	m_strName.Copy(_L("VR"));
	m_pstrExp = new(ELeave)CDesCArrayFlat(1);

	TBuf<20> temp;
	temp.AppendNum(m_pGlobal->m_pnParam[18]);
	temp.Append(_L("="));
	m_pstrExp->AppendL(temp);
}

TInt CInd_VR::GetDataLength()
{
	return 3;
}

void CInd_VR::WriteData(TDes8& aBuf)
{
	CGlobal::WriteInt8L(aBuf,1);
	CGlobal::WriteInt16L(aBuf,(TInt16)(m_pGlobal->m_pnParam[18]));
}

CInd_ZJLB::~CInd_ZJLB()
{

}


CInd_ZJLB* CInd_ZJLB::NewL(CBlockPicHis* outerPic)
{
	CInd_ZJLB* self=CInd_ZJLB::NewLC(outerPic);
	CleanupStack::Pop(); // self;
	return self;
}

CInd_ZJLB* CInd_ZJLB::NewLC(CBlockPicHis* outerPic)
{
	CInd_ZJLB* self = new (ELeave)CInd_ZJLB(outerPic);
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
}

CInd_ZJLB::CInd_ZJLB(CBlockPicHis* outerPic):CInd(outerPic)
{

}

void CInd_ZJLB::ConstructL()
{
	if(m_pGlobal->m_pnParam[21]==0)
		m_nExpSize = 1;
	else
		m_nExpSize = 2;
	CGlobal::GetDesFromID(m_strName, LOC_BUF_MENU_ZIJINLIUBIAN);
	m_pstrExp = new(ELeave)CDesCArrayFlat(2);

	TBuf<20> temp;
	CGlobal::GetDesFromID(temp, LOC_BUF_STR_IND_ZJLB_EXP1);
	m_pstrExp->AppendL(temp);
	temp.Zero();
	CGlobal::GetDesFromID(temp, LOC_BUF_STR_IND_ZJLB_EXP2);
	m_pstrExp->AppendL(temp);
}

void CInd_ZJLB::Draw(CFbsBitGc& g, const TInt& nFirst, const TInt& nDay)
{
	DrawAmtStick(g, 0, nFirst, nDay);
	if (m_nExpSize == 2)
	{
		DrawLine(g, 1, nFirst, nDay, m_pGlobal->g_rgbInd[1]);
	}
}

void CInd_ZJLB::DrawAmtStick(CFbsBitGc& g, const TInt& nExpPos, const TInt& nFirst, const TInt& nDay)
{
	TInt nExpFirst = GetExpFirst(nExpPos);
	if (nExpFirst < 0)
	{
		return;
	}

	TInt nW = p_OuterPic->m_nWidthPerDay/2-1;
	TInt nY0 = Value2Y(0);

	for (TInt i = nFirst; i<nDay; i++)
	{
		TInt64 lExpValue = GetExpValue(i, nExpPos);

		TInt nX = p_OuterPic->Pos2X(i-nFirst);
		TInt nY = Value2Y(lExpValue);
		if (lExpValue>0)
		{	
			if (nY==nY0)
			{
				nY -= 1;
			}
			CGlobal::DrawRect(g,nX-nW, nY, nX+nW, nY0, m_pGlobal->g_rgbRise, m_pGlobal->g_rgbRise);
			//CGlobal::DrawRect(g,nX-nW, nY, nX+nW+1, nY0+1, m_pGlobal->g_rgbRise, m_pGlobal->g_rgbRise);
		}
		else if (lExpValue<0)
		{
			if (nY==nY0)
			{
				nY += 1;
			}
			CGlobal::DrawRect(g,nX-nW, nY0, nX+nW, nY, m_pGlobal->g_rgbFall, m_pGlobal->g_rgbFall);
			//CGlobal::DrawRect(g,nX-nW, nY0+1, nX+nW+1, nY, m_pGlobal->g_rgbFall, m_pGlobal->g_rgbFall);
		}
		else
		{
			g.SetPenColor(m_pGlobal->g_rgbEqual);
			g.DrawLine(TPoint(nX-nW, nY0), TPoint(nX+nW, nY0));
		}
	}
}

void CInd_ZJLB::DrawCheck(CFbsBitGc& g, const TInt& anX, const TInt& nY, const TInt& nPos, const TInt16& sFieldID)
{
	TInt nX = anX;
	TBuf<4> strUp;
	CGlobal::GetDesFromID(strUp,LOC_BUF_STR_UP);
	TBuf<4> strDown;
	CGlobal::GetDesFromID(strDown,LOC_BUF_STR_DOWN);

	m_pGlobal->DrawString(g, m_strName, nX, nY-m_pGlobal->g_nFontSmallHeight, LEFT, m_pGlobal->g_rgbVolume, 2);
	nX += m_pGlobal->GetStringWidth(m_strName, 2);


	TField field;
	field.m_nFont = 0;
	field.m_nGoodsID = p_OuterPic->m_goods.m_nGoodsID;
	field.m_sID = sFieldID;

	TInt nDay = p_OuterPic->m_vDay.Count();
	for (TInt i = 0; i<m_nExpSize; i++)
	{
		TBuf<30> str;
		TBuf<16> temp;
		str.Copy((*m_pstrExp)[i]);
		if (i==1)
		{
			str.Append(_L("("));
			str.AppendNum(m_pGlobal->m_pnParam[21]);
			str.Append(_L(")"));
		}
		str.Append(_L("="));

		if (GetExpFirst(i) >= 0)
		{
			if (nPos>=0 && nPos<nDay)
			{
				field.m_lValue = GetExpValue(nPos, i);
			}
			else
			{
				field.m_lValue = 0;
			}
			field.GetString(temp);
			str.Append(temp);
		}

		m_pGlobal->DrawString(g, str, nX, nY-m_pGlobal->g_nFontSmallHeight, LEFT, m_pGlobal->g_rgbInd[i], 2);
		nX += m_pGlobal->GetStringWidth(str, 2);

		/*if(nPos>0)
		{
			TInt64 nDiff = GetExpValue(nPos, i) - GetExpValue(nPos-1, i);
			if(nDiff > 0)
				m_pGlobal->DrawString(g, strUp, nX, nY-m_pGlobal->g_nFontSmallHeight, LEFT, m_pGlobal->g_rgbRise, 2);
			else if(nDiff < 0)
				m_pGlobal->DrawString(g, strDown, nX, nY-m_pGlobal->g_nFontSmallHeight, LEFT, m_pGlobal->g_rgbFall, 2);
		}*/

		nX += m_pGlobal->GetStringWidth(_L("1"), 2);
	}
}

void CInd_ZJLB::WriteData(TDes8& aBuf)
{
	CGlobal::WriteInt8L(aBuf,1);
	CGlobal::WriteInt16L(aBuf,(TInt16)(m_pGlobal->m_pnParam[21]));
}

TInt CInd_ZJLB::GetDataLength()
{
	return 3;
}

CInd_ZJBY::~CInd_ZJBY()
{

}


CInd_ZJBY* CInd_ZJBY::NewL(CBlockPicHis* outerPic)
{
	CInd_ZJBY* self=CInd_ZJBY::NewLC(outerPic);
	CleanupStack::Pop(); // self;
	return self;
}

CInd_ZJBY* CInd_ZJBY::NewLC(CBlockPicHis* outerPic)
{
	CInd_ZJBY* self = new (ELeave)CInd_ZJBY(outerPic);
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
}

void CInd_ZJBY::Draw(CFbsBitGc& g, const TInt& nFirst, const TInt& nDay)
{
	for (int j = 0; j<m_nExpSize; j++)
	{
		DrawLine(g, j, nFirst, nDay, m_pGlobal->g_rgbAmt4[j]);
	}
}

void CInd_ZJBY::DrawCheck(CFbsBitGc& g, const TInt& anX, const TInt& nY, const TInt& nPos, const TInt16& sFieldID)
{	
	TInt nX = anX;
	m_pGlobal->DrawString(g, m_strName, nX, nY-m_pGlobal->g_nFontSmallHeight, LEFT, m_pGlobal->g_rgbVolume, 2);
	nX += m_pGlobal->GetStringWidth(m_strName, 2);

	TField field;
	field.m_nFont = 0;
	field.m_nGoodsID = p_OuterPic->m_goods.m_nGoodsID;
	field.m_sID = sFieldID;

	TInt nDay = p_OuterPic->m_vDay.Count();
	for (int i = 0; i<m_nExpSize; i++)
	{
		TBuf<30> str;
		TBuf<16> temp;
		str.Copy((*m_pstrExp)[i]);

		if (GetExpFirst(i) >= 0)
		{
			if (nPos>=0 && nPos<nDay)
				field.m_lValue = GetExpValue(nPos, i);
			else
				field.m_lValue = 0;
			field.GetString(temp);
			str.Append(temp);
		}

		m_pGlobal->DrawString(g, str, nX, nY-m_pGlobal->g_nFontSmallHeight, LEFT, m_pGlobal->g_rgbAmt4[i], 2);
		nX += m_pGlobal->GetStringWidth(str, 2);
		nX += 2;
	}
}

CInd_ZJBY::CInd_ZJBY(CBlockPicHis* outerPic):CInd(outerPic)
{

}

void CInd_ZJBY::ConstructL()
{
	m_nExpSize = 4;
	m_strName.Copy(_L(""));
	m_pstrExp = new(ELeave)CDesCArrayFlat(4);

	TBuf<20> temp;
	for(int i=0; i<4; i++)
	{
	    CGlobal::GetDesFromID(temp, LOC_BUF_STR_IND_ZJBY_EXP1+i);
	    m_pstrExp->AppendL(temp);
	}
//	TBuf<20> temp;
//	CGlobal::GetDesFromID(temp, LOC_BUF_STR_IND_ZJBY_EXP1);
//	m_pstrExp->AppendL(temp);
//	temp.Zero();
//	CGlobal::GetDesFromID(temp, LOC_BUF_STR_IND_ZJBY_EXP2);
//	m_pstrExp->AppendL(temp);
//	temp.Zero();
//	CGlobal::GetDesFromID(temp, LOC_BUF_STR_IND_ZJBY_EXP3);
//	m_pstrExp->AppendL(temp);
//	temp.Zero();
//	CGlobal::GetDesFromID(temp, LOC_BUF_STR_IND_ZJBY_EXP4);
//	m_pstrExp->AppendL(temp);
}

void CInd_ZJBY::CalcMM(const TInt& nFirst,const TInt& nDay)
{
	m_bCalcMM = ETrue;
	CInd::CalcMM(nFirst, nDay);
}

void CInd_ZJBY::WriteData(TDes8& aBuf)
{
	CGlobal::WriteInt8L(aBuf,0);
}

TInt CInd_ZJBY::GetDataLength()
{
	return 1;
}

CInd_DDBL::~CInd_DDBL()
{

}


CInd_DDBL* CInd_DDBL::NewL(CBlockPicHis* outerPic)
{
	CInd_DDBL* self=CInd_DDBL::NewLC(outerPic);
	CleanupStack::Pop(); // self;
	return self;
}

CInd_DDBL* CInd_DDBL::NewLC(CBlockPicHis* outerPic)
{
	CInd_DDBL* self = new (ELeave)CInd_DDBL(outerPic);
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
}

CInd_DDBL::CInd_DDBL(CBlockPicHis* outerPic):CInd(outerPic)
{

}

void CInd_DDBL::ConstructL()
{
	m_nExpSize = 3;
	m_strName.Copy(_L(""));
	m_pstrExp = new(ELeave)CDesCArrayFlat(3);

	TBuf<20> temp;
	CGlobal::GetDesFromID(temp, LOC_BUF_STR_DDBL_EXP1);
	m_pstrExp->AppendL(temp);
	temp.Zero();
	CGlobal::GetDesFromID(temp, LOC_BUF_STR_DDBL_EXP2);
	m_pstrExp->AppendL(temp);
	temp;
	CGlobal::GetDesFromID(temp, LOC_BUF_STR_DDBL_EXP3);
	m_pstrExp->AppendL(temp);
}

void CInd_DDBL::WriteData(TDes8& aBuf)
{
	CGlobal::WriteInt8L(aBuf,2);
	CGlobal::WriteInt16L(aBuf,(TInt16)(m_pGlobal->m_pnParam[24]));
	CGlobal::WriteInt16L(aBuf,(TInt16)(m_pGlobal->m_pnParam[25]));
}

TInt CInd_DDBL::GetDataLength()
{
	return 5;
}

void CInd_DDBL::Draw(CFbsBitGc& g, const TInt& nFirst, const TInt& nDay)
{
	DrawAmtStick(g, 0, nFirst, nDay);
	DrawLine(g, 1, nFirst, nDay, m_pGlobal->g_rgbInd[1]);
	DrawLine(g, 2, nFirst, nDay, m_pGlobal->g_rgbInd[2]);
}

void CInd_DDBL::DrawAmtStick(CFbsBitGc& g, const TInt& nExpPos, const TInt& nFirst, const TInt& nDay)
{
	TInt nExpFirst = GetExpFirst(nExpPos);
	if (nExpFirst<0)
	{
		return;
	}

	TInt nW = p_OuterPic->m_nWidthPerDay/2-1;
	TInt nY0 = Value2Y(0);

	for (int i = nFirst; i<nDay; i++)
	{
		TInt64 lExpValue = GetExpValue(i, nExpPos);

		int nX = p_OuterPic->Pos2X(i-nFirst);
		int nY = Value2Y(lExpValue);
		if (lExpValue>0)
		{	
			if (nY==nY0)
			{
				nY -= 1;
			}
			CGlobal::DrawRect(g,nX-nW, nY, nX+nW, nY0, m_pGlobal->g_rgbRise, m_pGlobal->g_rgbRise);
			//CGlobal::DrawRect(g,nX-nW, nY, nX+nW+1, nY0+1, m_pGlobal->g_rgbRise, m_pGlobal->g_rgbRise);
		}
		else if (lExpValue<0)
		{
			if (nY==nY0)
			{
				nY += 1;
			}
			CGlobal::DrawRect(g,nX-nW, nY0, nX+nW, nY, m_pGlobal->g_rgbFall, m_pGlobal->g_rgbFall);
			//CGlobal::DrawRect(g,nX-nW, nY0+1, nX+nW+1, nY, m_pGlobal->g_rgbFall, m_pGlobal->g_rgbFall);
		}
		else
		{
			g.SetPenColor(m_pGlobal->g_rgbEqual);
			g.DrawLine(TPoint(nX-nW, nY0), TPoint(nX+nW, nY0));
			//CGlobal::DrawRect(g, nX-nW, nY0, nX+nW, nY0, m_pGlobal->g_rgbEqual, m_pGlobal->g_rgbEqual);
		}
	}
}

void CInd_DDBL::DrawCheck(CFbsBitGc& g, const TInt& anX, const TInt& nY, 
						  const TInt& nPos, const TInt16& sFieldID)
{
	TInt nX = anX;
	TBuf<4> strUp;
	CGlobal::GetDesFromID(strUp,LOC_BUF_STR_UP);
	TBuf<4> strDown;
	CGlobal::GetDesFromID(strDown,LOC_BUF_STR_DOWN);

	m_pGlobal->DrawString(g, m_strName, nX, nY-m_pGlobal->g_nFontSmallHeight, LEFT, m_pGlobal->g_rgbVolume, 2);
	nX += m_pGlobal->GetStringWidth(m_strName, 2);

	TField field;
	field.m_nFont = 0;
	field.m_nGoodsID = p_OuterPic->m_goods.m_nGoodsID;
	field.m_sID = sFieldID;

	TInt nDay = p_OuterPic->m_vDay.Count();
	for (int i = 0; i<m_nExpSize; i++)
	{
		TBuf<30> str;
		TBuf<16> temp;
		str.Copy((*m_pstrExp)[i]);
		if (i == 1)
		{
			str.Append(_L("("));
			str.AppendNum(m_pGlobal->m_pnParam[24]);
			str.Append(_L("}"));
		}
		if (i == 2)
		{
			str.Append(_L("("));
			str.AppendNum(m_pGlobal->m_pnParam[25]);
			str.Append(_L("}"));
		}
		str.Append(_L("="));

		TInt expV = GetExpFirst(i);
		if (expV>=0)
		{
			if (nPos>=0&&nPos<nDay)
				field.m_lValue = GetExpValue(nPos, i);
			else
				field.m_lValue = 0;
			field.GetString(temp);
			str.Append(temp);
		}
		m_pGlobal->DrawString(g, str, nX, nY-m_pGlobal->g_nFontSmallHeight, LEFT, m_pGlobal->g_rgbInd[i], 2);
		nX += m_pGlobal->GetStringWidth(str, 2);

		/*if(nPos>0)
		{
			TInt64 nDiff = GetExpValue(nPos, i) - GetExpValue(nPos-1, i);
			if(nDiff > 0)
				m_pGlobal->DrawString(g, strUp, nX, nY-m_pGlobal->g_nFontSmallHeight, LEFT, m_pGlobal->g_rgbRise, 2);
			else if(nDiff < 0)
				m_pGlobal->DrawString(g, strDown, nX, nY-m_pGlobal->g_nFontSmallHeight, LEFT, m_pGlobal->g_rgbFall, 2);
		}*/

		nX += m_pGlobal->GetStringWidth(_L("1"), 2);
	}
}

CInd_CJZJ::~CInd_CJZJ()
{

}


CInd_CJZJ* CInd_CJZJ::NewL(CBlockPicHis* outerPic)
{
	CInd_CJZJ* self=CInd_CJZJ::NewLC(outerPic);
	CleanupStack::Pop(); // self;
	return self;
}

CInd_CJZJ* CInd_CJZJ::NewLC(CBlockPicHis* outerPic)
{
	CInd_CJZJ* self = new (ELeave)CInd_CJZJ(outerPic);
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
}

CInd_CJZJ::CInd_CJZJ(CBlockPicHis* outerPic):CInd(outerPic)
{

}

void CInd_CJZJ::ConstructL()
{
	m_nExpSize = 3;
	m_strName.Copy(_L(""));
	m_pstrExp = new(ELeave)CDesCArrayFlat(3);

	TBuf<20> temp;
	CGlobal::GetDesFromID(temp, LOC_BUF_STR_IND_CJZJ_EXP1);
	m_pstrExp->AppendL(temp);
	temp.Zero();
	CGlobal::GetDesFromID(temp, LOC_BUF_STR_IND_CJZJ_EXP2);
	m_pstrExp->AppendL(temp);
	temp.Zero();
	CGlobal::GetDesFromID(temp, LOC_BUF_STR_IND_CJZJ_EXP3);
	m_pstrExp->AppendL(temp);
}

void CInd_CJZJ::WriteData(TDes8& aBuf)
{
	CGlobal::WriteInt8L(aBuf,0);
}

TInt CInd_CJZJ::GetDataLength()
{
	return 1;
}

void CInd_CJZJ::Draw(CFbsBitGc& g, const TInt& nFirst, const TInt& nDay)
{
	DrawAmtStick(g, 0, nFirst, nDay);
	DrawLine(g, 1, nFirst, nDay, m_pGlobal->g_rgbInd[2]);
	DrawLine(g, 2, nFirst, nDay, m_pGlobal->g_rgbInd[0]);
}

void CInd_CJZJ::DrawAmtStick(CFbsBitGc& g, const TInt& nExpPos, const TInt& nFirst, const TInt& nDay)
{
	TInt nExpFirst = GetExpFirst(nExpPos);
	if (nExpFirst<0)
	{
		return;
	}

	TInt nW = p_OuterPic->m_nWidthPerDay/2-1;
	TInt nY0 = Value2Y(0);

	for (int i = nFirst; i<nDay; i++)
	{
		TInt64 lExpValue = GetExpValue(i, nExpPos);

		int nX = p_OuterPic->Pos2X(i-nFirst);
		int nY = Value2Y(lExpValue);
		if (lExpValue>0)
		{	
			if (nY==nY0)
			{
				nY -= 1;
			}
			CGlobal::DrawRect(g,nX-nW, nY, nX+nW, nY0, m_pGlobal->g_rgbRise, m_pGlobal->g_rgbRise);
			//CGlobal::DrawRect(g,nX-nW, nY, nX+nW+1, nY0+1, m_pGlobal->g_rgbRise, m_pGlobal->g_rgbRise);
		}
		else if (lExpValue<0)
		{
			if (nY==nY0)
			{
				nY += 1;
			}
			CGlobal::DrawRect(g,nX-nW, nY0, nX+nW, nY, m_pGlobal->g_rgbFall, m_pGlobal->g_rgbFall);
			//CGlobal::DrawRect(g,nX-nW, nY0+1, nX+nW+1, nY, m_pGlobal->g_rgbFall, m_pGlobal->g_rgbFall);
		}
		else
		{
			g.SetPenColor(m_pGlobal->g_rgbEqual);
			g.DrawLine(TPoint(nX-nW, nY0), TPoint(nX+nW, nY0));
			//CGlobal::DrawRect(g, nX-nW, nY0, nX+nW, nY0, m_pGlobal->g_rgbEqual, m_pGlobal->g_rgbEqual);
		}
	}
}

void CInd_CJZJ::DrawCheck(CFbsBitGc& g, const TInt& anX, const TInt& nY, 
						  const TInt& nPos, const TInt16& sFieldID)
{
	TInt nX = anX;
	TBuf<4> strUp;
	CGlobal::GetDesFromID(strUp,LOC_BUF_STR_UP);
	TBuf<4> strDown;
	CGlobal::GetDesFromID(strDown,LOC_BUF_STR_DOWN);

	m_pGlobal->DrawString(g, m_strName, nX, nY-m_pGlobal->g_nFontSmallHeight, LEFT, m_pGlobal->g_rgbVolume, 2);
	nX += m_pGlobal->GetStringWidth(m_strName, 2);

	TField field;
	field.m_nFont = 0;
	field.m_nGoodsID = p_OuterPic->m_goods.m_nGoodsID;
	field.m_sID = sFieldID;

	TInt nDay = p_OuterPic->m_vDay.Count();
	for (int i = 0; i<m_nExpSize; i++)
	{
		TBuf<30> str;
		TBuf<16> temp;
		str.Copy((*m_pstrExp)[i]);
		str.Append(_L("="));

		TInt expV = GetExpFirst(i);
		if (expV>=0)
		{
			if (nPos>=0&&nPos<nDay)
				field.m_lValue = GetExpValue(nPos, i);
			else
				field.m_lValue = 0;
			field.GetString(temp);
			str.Append(temp);
		}
		if (i==1)
		{
			m_pGlobal->DrawString(g, str, nX, nY-m_pGlobal->g_nFontSmallHeight, LEFT, m_pGlobal->g_rgbInd[2], 2);
		}
		else
		{
			m_pGlobal->DrawString(g, str, nX, nY-m_pGlobal->g_nFontSmallHeight, LEFT, m_pGlobal->g_rgbInd[0], 2);
		}
		nX += m_pGlobal->GetStringWidth(str, 2);

		if(nPos>0)
		{
			TInt64 nDiff = GetExpValue(nPos, i) - GetExpValue(nPos-1, i);
			if(nDiff > 0)
				m_pGlobal->DrawString(g, strUp, nX, nY-m_pGlobal->g_nFontSmallHeight, LEFT, m_pGlobal->g_rgbRise, 2);
			else if(nDiff < 0)
				m_pGlobal->DrawString(g, strDown, nX, nY-m_pGlobal->g_nFontSmallHeight, LEFT, m_pGlobal->g_rgbFall, 2);
		}

		nX += m_pGlobal->GetStringWidth(_L("1"), 2);
	}
}

CInd_CMJS::~CInd_CMJS()
{

}


CInd_CMJS* CInd_CMJS::NewL(CBlockPicHis* outerPic)
{
	CInd_CMJS* self=CInd_CMJS::NewLC(outerPic);
	CleanupStack::Pop(); // self;
	return self;
}

CInd_CMJS* CInd_CMJS::NewLC(CBlockPicHis* outerPic)
{
	CInd_CMJS* self = new (ELeave)CInd_CMJS(outerPic);
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
}

CInd_CMJS::CInd_CMJS(CBlockPicHis* outerPic):CInd(outerPic)
{

}

void CInd_CMJS::ConstructL()
{
	m_nExpSize = 2;
	m_strName.Copy(_L(""));
	m_pstrExp = new(ELeave)CDesCArrayFlat(2);

	TBuf<20> temp;
	CGlobal::GetDesFromID(temp, LOC_BUF_STR_IND_CMJS_EXP1);
	m_pstrExp->AppendL(temp);
	temp.Zero();
	CGlobal::GetDesFromID(temp, LOC_BUF_STR_IND_CMJS_EXP2);
	m_pstrExp->AppendL(temp);
}

void CInd_CMJS::WriteData(TDes8& aBuf)
{
	CGlobal::WriteInt8L(aBuf,0);
}

TInt CInd_CMJS::GetDataLength()
{
	return 1;
}

void CInd_CMJS::Draw(CFbsBitGc& g, const TInt& nFirst, const TInt& nDay)
{
	DrawAmtStick(g, 0, nFirst, nDay);
	DrawLine(g, 1, nFirst, nDay, m_pGlobal->g_rgbInd[1]);
}

void CInd_CMJS::DrawAmtStick(CFbsBitGc& g, const TInt& nExpPos, const TInt& nFirst, const TInt& nDay)
{
	TInt nExpFirst = GetExpFirst(nExpPos);
	if (nExpFirst<0)
	{
		return;
	}

	TInt nW = p_OuterPic->m_nWidthPerDay/2-1;
	TInt nY0 = Value2Y(0);

	for (int i = nFirst; i<nDay; i++)
	{
		TInt64 lExpValue = GetExpValue(i, nExpPos);

		int nX = p_OuterPic->Pos2X(i-nFirst);
		int nY = Value2Y(lExpValue);
		if (lExpValue>0)
		{	
			if (nY==nY0)
			{
				nY -= 1;
			}
			CGlobal::DrawRect(g,nX-nW, nY, nX+nW, nY0, m_pGlobal->g_rgbRise, m_pGlobal->g_rgbRise);
			//CGlobal::DrawRect(g,nX-nW, nY, nX+nW+1, nY0+1, m_pGlobal->g_rgbRise, m_pGlobal->g_rgbRise);
		}
		else if (lExpValue<0)
		{
			if (nY==nY0)
			{
				nY += 1;
			}
			CGlobal::DrawRect(g,nX-nW, nY0, nX+nW, nY, m_pGlobal->g_rgbFall, m_pGlobal->g_rgbFall);
			//CGlobal::DrawRect(g,nX-nW, nY0+1, nX+nW+1, nY, m_pGlobal->g_rgbFall, m_pGlobal->g_rgbFall);
		}
		else
		{
			g.SetPenColor(m_pGlobal->g_rgbEqual);
			g.DrawLine(TPoint(nX-nW, nY0), TPoint(nX+nW, nY0));
			//CGlobal::DrawRect(g, nX-nW, nY0, nX+nW, nY0, m_pGlobal->g_rgbEqual, m_pGlobal->g_rgbEqual);
		}
	}
}

void CInd_CMJS::DrawCheck(CFbsBitGc& g, const TInt& anX, const TInt& nY, 
						  const TInt& nPos, const TInt16& sFieldID)
{
	TInt nX = anX;
	TBuf<4> strUp;
	CGlobal::GetDesFromID(strUp,LOC_BUF_STR_UP);
	TBuf<4> strDown;
	CGlobal::GetDesFromID(strDown,LOC_BUF_STR_DOWN);

	m_pGlobal->DrawString(g, m_strName, nX, nY-m_pGlobal->g_nFontSmallHeight, LEFT, m_pGlobal->g_rgbVolume, 2);
	nX += m_pGlobal->GetStringWidth(m_strName, 2);

	TField field;
	field.m_nFont = 0;
	field.m_nGoodsID = p_OuterPic->m_goods.m_nGoodsID;
	field.m_sID = sFieldID;

	TInt nDay = p_OuterPic->m_vDay.Count();
	for (int i = 0; i<m_nExpSize; i++)
	{
		TBuf<30> str;
		TBuf<16> temp;
		str.Copy((*m_pstrExp)[i]);
		str.Append(_L("="));

		TInt expV = GetExpFirst(i);
		if (expV>=0)
		{
			if (nPos>=0&&nPos<nDay)
				field.m_lValue = GetExpValue(nPos, i);
			else
				field.m_lValue = 0;
			field.GetString(temp);
			str.Append(temp);
		}
		m_pGlobal->DrawString(g, str, nX, nY-m_pGlobal->g_nFontSmallHeight, LEFT, m_pGlobal->g_rgbInd[i], 2);
		nX += m_pGlobal->GetStringWidth(str, 2);

		if(nPos>0)
		{
			TInt64 nDiff = GetExpValue(nPos, i) - GetExpValue(nPos-1, i);
			if(nDiff > 0)
				m_pGlobal->DrawString(g, strUp, nX, nY-m_pGlobal->g_nFontSmallHeight, LEFT, m_pGlobal->g_rgbRise, 2);
			else if(nDiff < 0)
				m_pGlobal->DrawString(g, strDown, nX, nY-m_pGlobal->g_nFontSmallHeight, LEFT, m_pGlobal->g_rgbFall, 2);
		}

		nX += m_pGlobal->GetStringWidth(_L("1"), 2);
	}
}
